import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TreeVO, TreeForm, TreeQuery } from '@/api/demo/tree/types';

/**
 * 查询树表展示列表
 *
 * @param {object} query
 */
export const listTree = (query?: TreeQuery): AxiosPromise<TreeVO[]> => {
  return request({
    url: '/demo/tree/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询树表展示详细
 *
 * @param {string} addressId
 */
export const getTree = (addressId: string | number): AxiosPromise<TreeVO> => {
  return request({
    url: '/demo/tree/' + addressId,
    method: 'get'
  });
};

/**
 * 新增树表展示
 *
 * @param {object} data
 */
export const addTree = (data: TreeForm)=> {
  return request({
    url: '/demo/tree/add',
    method: 'post',
    data: data
  });
};

/**
 *  修改树表展示
 *
 * @param {object} data
 */
export const updateTree = (data: TreeForm) => {
  return request({
    url: '/demo/tree/edit',
    method: 'put',
    data: data
  });
};

/**
 * 删除树表展示
 *
 * @param {string} addressId
 */
export const delTree = (addressId: string | number | Array<string | number>) => {
  return request({
    url: '/demo/tree/' + addressId,
    method: 'delete'
  });
};

